//
//  MeiTableCell.m
//  MyProject
//
//  Created by dllo on 15/11/17.
//  Copyright © 2015年 蓝鸥0825. All rights reserved.
//

#import "MeiTableCell.h"
#import "UIImageView+WebCache.h"


#define WIDTH self.frame.size.width
#define HEIGHT self.frame.size.height

@implementation MeiTableCell

- (void)awakeFromNib {
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self create];
    }
    return self;
}


- (void)create{
    
    self.label = [[UILabel alloc] init];
    [self addSubview:self.label];
    self.label.font = [UIFont systemFontOfSize:30 weight:25];
    self.label.textAlignment = NSTextAlignmentCenter;
    
    //      在刚开始时已经走过这个方法, 所以在下一页写其它东西的创建的时候用 self.frame.size.width为空
    self.viewF = [[MeiFView alloc] init];
    [self.contentView addSubview:self.viewF];
    
    self.viewS = [[MeiSView alloc] init];
    [self addSubview:self.viewS];
}


- (void)layoutSubviews{
    
    [super layoutSubviews];
    
    self.label.frame = CGRectMake(HEIGHT / 100 * 2, 0, WIDTH, HEIGHT / 100 * 7);

    
    self.viewF.frame = CGRectMake(0, HEIGHT / 100 * 7, WIDTH, HEIGHT / 100 * 40);
    self.viewF.collection.frame = CGRectMake(WIDTH / 100 * 4, 0, WIDTH / 100 * 90, HEIGHT / 100 * 35);
    self.viewF.layOut.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    self.viewF.layOut.minimumLineSpacing = 0;
    self.viewF.layOut.itemSize = CGSizeMake( WIDTH / 100 * 90, HEIGHT / 100 * 35);
    self.viewF.collection.pagingEnabled = YES;//一定要记住设置最小行间距
    
    self.viewS.frame = CGRectMake(0, HEIGHT / 100 * 47, WIDTH, HEIGHT / 100 * 53);
    self.viewS.tabel.frame = CGRectMake(WIDTH / 100 * 4,  0, WIDTH / 100 * 80, HEIGHT / 100 * 53);
    self.viewS.tabel.rowHeight = HEIGHT / 100 * 53;
    
//    self.label.layer.borderWidth = 1;
//    self.viewS.layer.borderWidth = 1;
//    self.viewS.tabel.layer.borderWidth = 1;
//    self.viewF.layer.borderWidth = 1;
}

- (void)setModel:(MeiModel *)model{
    
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    self.label.text = model.title;
    self.viewF.array = model.items;
    self.viewS.array = model.today_events;
}




@end
